<script setup lang="ts">
import { OIcon } from '@opensig/opendesign';
import DocTools from '@/components/doc/DocTools.vue';
import IconShouqi from '~icons/app/icon-shouqi.svg';
import IconZhankai from '~icons/app/icon-zhankai.svg';
import { storeToRefs } from 'pinia';
import { useCommonStore } from '@/stores/common.ts';

const commonStore = useCommonStore();

defineProps<{
  title: string;
  open: boolean;
}>()
const emits = defineEmits(['toggle-menu']);
const toggleMenu = () => {
  emits('toggle-menu');
}

const { showMobileNav } = storeToRefs(commonStore);
</script>

<template>
<div class="sub-header" :style="{
  '--z-index': showMobileNav ? -2 : 0,
}">
  <div class="sub-header-left">
   <OIcon @click="toggleMenu">
     <IconShouqi v-if="open"></IconShouqi>
     <IconZhankai v-else></IconZhankai>
   </OIcon>
    <div class="doc-title">{{ title }}</div>
  </div>
  <div class="sub-header-right">
    <ClientOnly>
      <DocTools></DocTools>
    </ClientOnly>
  </div>
</div>
</template>

<style scoped lang="scss">
.sub-header {
  height: var(--layout-doc-header-height);
  color: var(--o-color-info1);
  background-color: var(--o-color-fill2);
  position: fixed;
  top: var(--layout-header-height);
  left: 0;
  right: 0;
  z-index: calc(var(--layout-header-z-index) + var(--z-index));
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--grid--layout-padding);
  :deep(.o-icon) {
    path {
      fill: currentColor;
    }
  }
  &::before {
    top: 0;
    bottom: 0;
    right: 0;
    box-shadow: 0 3px 8px rgba(var(--o-mixedgray-14), 0.05);
    content: '';
    left: 0;
    pointer-events: none;
    position: absolute;
  }
  .sub-header-left {
    color: var(--o-color-info1);
    display: flex;
    align-items: center;
    .o-icon {
      cursor: pointer;
      font-size: 24px;
      margin-right: 8px;
    }
    .doc-title {
      @include h1;
      font-weight: 500;
    }
  }
  .sub-header-right {
    color: var(--o-color-info2);
  }
  :deep(.sub-header-right) {
    .o-icon {
      font-size: 16px;

    }
  }
}
</style>